﻿using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS.Web;
using IFRS_Global;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class IFRS_WIN12_3V : PageBase
{
    #region "---------- Events -----------"
    bool ValidIDCard = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Page.IsPostBack || Page.IsCallback))
        {
            this.ViewMenu();
            if (Request.QueryString["id"] != null)
            {
                this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
            }
            SetControl();
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }
    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN12_1S.aspx");

    }   
    #endregion "---------- Events -----------"

    #region "----------  Methods -----------"
    private void SetControl()
    {
        SetControlReadOnly(form_control);
    }
    private void ViewMenu()
    {
        MenuTitleBar = Resources.ifrsMenu.WIN12_3V;
    }
    private void BindData(int ID)
    {
        List<Customer> customer = new List<Customer>();
        DataTable dt = new SPR_CUSTOMER().SEARCH_BYID(ID);
        if (dt.Rows.Count > 0)
        {
            ConvertHelper.ConvertDataTableToObject(dt, customer);
            txtCustomerCode.Text = customer[0].CustomerCode;
            rbtCustpmerType_Individuals.Checked = customer[0].CustomerType == 1 ? true : false;
            rbtCustpmerType_Firms.Checked = customer[0].CustomerType == 2 ? true : false;

            if (customer[0].CustomerType == 1)
                txtLicenseCardNo.Text = customer[0].LicenseNo;
            else
                txtLicenseNo.Text = customer[0].LicenseNo;

            txtPassportNo.Text = customer[0].PassportNo;
            txtIssueAmount.Text = customer[0].IssueAmount.DecimalToString();
            rbtStockExChangeRegister.SelectedValue = customer[0].StockExchangeRegister.IntToString();
            rbtOccupationType.SelectedValue = customer[0].OccupationType.IntToString();
            rbtResidentArea.SelectedValue = customer[0].ResidentArea.IntToString();
        }
    }
    #endregion "----------  Methods -----------"
}